@extends('admin/layout/master')
@section('title', '参数修改')
@section('title2', '参数修改')

@section('action')
    <a class="layui-btn layui-btn-small layui-btn-normal usersAdd_btn" href="{{ url('admin/configs/index') }}"><i class="layui-icon"></i>参数列表</a>
@endsection

@section('content')
    <div class="error">
        @if (count($errors) > 0)
            <div class="alert alert-danger">
                错误列表：
                <ul>
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif
    </div>

    <form class="layui-form" name="mainform" action="{{ url('/admin/configs/update',['id'=>$olddata->id]) }}" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label">配置名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" required  lay-verify="required" placeholder="请输入配置名称" value="{{ $olddata->name }}" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">配置描述</label>
            <div class="layui-input-block">
                <input type="text" name="info" required  lay-verify="required" placeholder="请输入配置名称" value="{{ $olddata->info }}" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">配置类型</label>
            <div class="layui-input-block">
                <select name="type" lay-verify="required">
                    <option value=""></option>
                    <option value="string" <?php if($olddata->type == 'string'){echo 'selected';} ?>>string</option>
                    <option value="text" <?php if($olddata->type == 'text'){echo 'selected';} ?>>text</option>
                    <option value="enum" <?php if($olddata->type == 'enum'){echo 'selected';} ?>>enum</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">配置值</label>
            <div class="layui-input-block">
                <input type="text" name="value" placeholder="请输入配置名称" value="{{ $olddata->value }}" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">配置分组</label>
            <div class="layui-input-block">
                <select name="group_id" lay-verify="required">
                    <option value=""></option>
                    @foreach($configGroupData as $v)
                        <option value="{{ $v->id }}" <?php if($olddata->group_id == $v->id){echo 'selected';} ?>>{{ $v->name }}</option>
                    @endforeach
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                {{ csrf_field() }}
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
@endsection

@section('layuijs')
    <script>
        //一般直接写在一个js文件中
        layui.use(['layer', 'form', 'upload'], function(){
            var layer = layui.layer
                    ,form = layui.form;
        });
    </script>
@endsection